#!/usr/bin/env python
"""
创建默认超级用户的脚本
"""
import os
import django

# 设置Django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'admin_learn_project.settings')
django.setup()

from core.models import CustomUser

def create_superuser():
    """创建默认超级用户"""
    username = 'admin'
    email = 'admin@example.com'
    password = 'admin123'

    if not CustomUser.objects.filter(username=username).exists():
        user = CustomUser.objects.create_superuser(
            username=username,
            email=email,
            password=password,
            first_name='管理员',
            last_name='Admin',
            is_vip=True,
            vip_level=10
        )
        print(f'已创建超级用户: {username}')
        print(f'密码: {password}')
        print(f'邮箱: {email}')
    else:
        print(f'超级用户 {username} 已存在')

if __name__ == '__main__':
    create_superuser()
